<!-- 登录拦截 -->
<script src="../assets/js/jquery.min.js"></script>
<script>
    var id = sessionStorage.getItem('userId')
    if (!id) {
        location.href = 'login.html'
    }
</script>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理-文章列表</title>
    <link rel="stylesheet" href="../assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="../assets/css/admin/common.css">
    <link rel="stylesheet" href="../assets/css/admin/writeArticle.css">
    <link rel="stylesheet" href="../assets/utils/nprogress/nprogress.css">
    <script src="../assets/utils/nprogress/nprogress.js"></script>
</head>

<body>
    <script>
        NProgress.start()
    </script>
    <!-- 1、左边导航栏区域 -->
    <div class="aside">
        <!-- 1-1-用户头像信息 -->
        <div class="user-info" id="userData">
            <img src="/assets/uploads/5.jpg" alt="">
            <h3>梦里百川</h3>
        </div>
        <!-- 1-2-菜单栏信息 -->
        <ul class="nav">
            <li>
                <a href="index.html"><span class="glyphicon glyphicon-equalizer"></span>首页</a>
            </li>

            <li class="active">
                <a href="#menu-posts" class="collapsed" data-toggle="collapse">
                    <span class="glyphicon glyphicon-level-up"></span>文章<i class="glyphicon glyphicon-menu-down"></i>
                </a>
                <ul id="menu-posts" class="collapse in">
                    <li><a href="allArticle.html">所有文章</a></li>
                    <li class="active"><a href="writeArticle.html">写文章</a></li>
                    <li><a href="catalogArticle.html">文章类别</a></li>
                </ul>
            </li>

            <li>
                <a href="comments.html"><span class="glyphicon glyphicon-equalizer"></span>评论</a>
            </li>
            <li>
                <a href="users.html"><span class="glyphicon glyphicon-equalizer"></span>用户</a>
            </li>
            <li>
                <a href="#menu-settings" class="collapsed" data-toggle="collapse">
                    <span class="glyphicon glyphicon-equalizer"></span>设置<i class="glyphicon glyphicon-menu-down"></i>
                </a>
                <ul id="menu-settings" class="collapse">
                    <li><a href="rotation.html">图片轮播</a></li>
                    <li><a href="settings.html">网站设置</a></li>
                </ul>
            </li>
        </ul>
    </div>
    <!-- 2、主体内容区域 -->
    <div class="main">
        <!-- 2-1-顶部小白条 -->
        <div class="navbar">
            <h3 class="title">编辑博客</h3>
            <ul>
                <li><a href="resetPwd.html"><i class="glyphicon glyphicon-wrench"></i> 修改密码</a></li>
                <li><a href="login.html"><i class="glyphicon glyphicon-off"></i> 退出登录</a></li>
            </ul>
        </div>
        <!-- 2-2-主体内容 -->
        <div class="container-box" id="editArtic">
            <!-- 2-2-1表单 -->
            <form action="" class="row addArtic" id="addForm">
                <div class="col-md-9">
                    <div class="form-group">
                        <label for="title">标题</label>
                        <input type="text" class="form-control title" id="title" name="title" placeholder="文章标题">
                    </div>
                    <div class="form-group">
                        <label for="area">内容</label>
                        <textarea rows="18" cols="20" class="form-control" id="area" name="content"
                            placeholder="开始创作之旅"></textarea>
                    </div>
                </div>
                <div class="col-md-3">
                    <h3>选择文章封面</h3>
                    <div class="form-group articImg">
                        <div class="user-img">
                            <label for="InputFile" class="input-img">
                                <input type="file" id="InputFile">
                                <img src="/assets/images/fm.jfif" id="cover" alt="">
                            </label>
                        </div>
                        <input type="hidden" name="thumbnail" id="hiddenAvatar">
                    </div>
                    <div class="form-group">
                        <label for="category">所属分类</label>
                        <select id="category" class="form-control" name="category">
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="created">发布时间</label>
                        <input id="created" class="form-control" type="date" name="createAt">
                    </div>
                    <div class="form-group">
                        <label for="state">状态</label>
                        <select id="state" class="form-control" name="state">
                            <option value="0">草稿</option>
                            <option value="1">已发布</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <button class="btn btn-primary" type="submit">保存</button>
                    </div>
                </div>
            </form>
        </div>

    </div>


    <!-- js -->
    <script src="../assets/js/jquery.min.js"></script>
    <script src="../assets/js/bootstrap.min.js"></script>
    <script src="../assets/js/common.js"></script>
    <script src="../assets/utils/art-template/template-web.js"></script>
    <script src="../assets/js/writeArticle.js"></script>
    <script>
        NProgress.done()
    </script>
    <!-- 文章分类模板-开始 -->
    <script type="text/html" id="categoryTpl">
        {{each data}}
        <option value="{{$value._id}}">{{$value.title}}</option>
        {{/each}}
    </script>
    <!-- 文章分类模板-结束 -->
    <!-- 文章修改模板-开始 -->
    <script type="text/html" id="editTpl">
        <form action="" class="row addArtic" id="editForm" data-id="{{_id}}">
            <div class="col-md-9">
                <div class="form-group">
                    <label for="title">标题</label>
                    <input type="text" class="form-control title" id="title" name="title" value="{{title}}">
                </div>
                <div class="form-group">
                    <label for="content">内容</label>
                    <textarea rows="18" cols="20" class="form-control" id="content" name="content"
                        value="{{content}}">{{content}}</textarea>
                </div>
            </div>
            <div class="col-md-3">
                <h3>选择文章封面</h3>
                <div class="form-group articImg">
                    <div class="user-img">
                        <label for="InputFile" class="input-img">
                            <input type="file" id="InputFile">
                            {{if thumbnail}}
                            <img src="{{thumbnail}}" id="cover" alt="">
                            {{else}}
                            <img id="cover" src="\uploads\defaultCover.jfif">
                            {{/if}}
                            <input type="hidden" name="thumbnail" id="hiddenAvatar" value="thumbnail">
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="category">所属分类</label>
                    <select id="category" class="form-control" name="category">
                        {{each categories }}
                        <option {{category._id == $value._id?'selected':''}} name="category"  value="{{$value._id}}">{{$value.title}}</option>
                        {{/each}}
                    </select>
                </div>
                <div class="form-group">
                    <label for="created">发布时间</label>
                    <input id="created" class="form-control" type="date" name="createAt" value="{{createTime}}">
                </div>
                <div class="form-group">
                    <label for="status">状态</label>
                    <select id="status" class="form-control" name="state">
                        <option value="0" {{state==0?'selected':''}}>草稿</option>
                        <option value="1" {{state==1?'selected':''}}>已发布</option>
                    </select>
                </div>
                <div class="form-group">
                    <button class="btn btn-primary" type="submit">修改</button>
                </div>
            </div>
        </form>
    </script>
    <!-- 文章修改模板-结束 -->

</body>

</html>